﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using ModelLibrary;

namespace WebC
{
    public partial class base_brandcompany : clsBaseForm
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Ajax.Utility.RegisterTypeForAjax(typeof(base_brandcompany));
            if (!IsPostBack)
            {
                loadInfo();
            }
        }

        public void loadInfo()
        {
            BaseInfo baseinfo = null;
            string sModelName = "";
            DataTable dt = null;
            try
            {
                baseinfo = new BaseInfo();
                if (!checkModelRightById(537, ref sModelName, (clsBaseLib)baseinfo))
                {
                    errorUrl(string.Format("你没有“{0}”的权限,请与管理员联系！", sModelName));
                    return;
                }
                sModelFullName = sModelName;
                lbBrandName.Text = baseinfo.getBrandNameById(m_Id);
                dt = baseinfo.getBrandCompany(m_Id);
            }
            catch (Exception e)
            {
                errorUrl(Convert.ToString(e));
            }
            finally
            {
                if (baseinfo != null)
                {
                    baseinfo.Dispose();
                }
            }
            if(dt != null)
            {
                rpttblInfo.DataSource = dt;
                rpttblInfo.DataBind();
            }
        }

        int m_Id
        {
            get
            {
                return Convert.ToInt32(Request["id"]);
            }
        }

        [Ajax.AjaxMethod]
        public bool setData(int iUId, string sRoleIds)
        {
            bool bResult = false;
            BaseInfo baseinfo = null;
            try
            {
                baseinfo = new BaseInfo();
                baseinfo.setBrandCompany(iUId, sRoleIds);
                bResult = true;
            }
            catch
            {
                bResult = false;
            }
            finally
            {
                if (baseinfo != null)
                {
                    baseinfo.Dispose();
                }
            }
            return bResult;
        }
    }
}